
#coding:utf-8    
#使用自己的域名后，加上共享IP，发了2个QQ邮件，是可以送到的
#发送 11万封邮件，得到 1万的转化率 5%
#每天发2000封邮件, 单数

import requests                                                          
import hashlib
import time
import csv


url="http://api.sendcloud.net/apiv2/mail/send"                       
filepath = '//Users//elsa//Desktop//proj//python//jd_maotai//learning_notebook-master//qqemail//splitdata//split_1.csv'

csv_reader = csv.reader(open(filepath, encoding='utf-8'))

for row in csv_reader:
    #date|  name  |qq  
    rowarray =  len(row)  
    rowdate = row[1]
    
    if rowarray>3 and rowdate!='datetime' :
        
        rowname = row[2]
        #rowqq = row[3]+'@qq.com'
        rowqq = '25867114@qq.com'
        
        print(rowdate,rowname,rowqq)
          
        qq_subject = rowname+" 百-万-比_特-币大赠送、亚洲最大的场-外-交-易平台"
    
        #hash_subject = hashlib.md5()   
        #hash_subject.update(qq_subject.encode('utf-8'))   
        #qq_subject = qq_subject + hash_subject.hexdigest() 
  
        qq_html =" <p>  \
<span style='background-color:;'></span> \
</p> \
<h1 style='text-align:center;font-size:41px;font-family:Raleway, &quot;color:white;background-color:#2C3E50;'> \
	<span style='color:aqua;'>比-特电报</span>-<span style='color:coral;'>币圈社交神器</span> \
</h1> \
<span style='font-family:Helvetica, &quot;'></span> \
<p style='font-family:Helvetica, &quot;font-size:14px;'> \
	&nbsp; <span style='font-size:14px;'>您好： " + rowname
    
        qq_html = qq_html + "<h1> \
	<span style='color:#337FE5;'>免费梯子 直连电报（Telegram）</span><br /> \
<span style='color:#337FE5;'>大量免费糖果不再错过</span><br /> \
<span style='color:#337FE5;'>币圈大佬都在用</span><br /> \
<span style='color:#337FE5;'>币情动态、尽在掌握中</span> \
<span style='color:#337FE5;'>下载 </span> \
</h1><p>	<br /></p>"
    
    
        hash_html  = hashlib.sha256()
        hash_html.update(qq_html.encode('utf-8'))
        qq_html    = qq_html + hash_html.hexdigest()
   
        # 您需要登录SendCloud创建API_USER，使用API_USER和API_KEY才可以进行邮件的发送。
        params = {"apiUser": "tomtao_8222_Qzo83E", \
                  "apiKey" : "Q5pqqRDfgjF739Th",\
                  "from" : "service@8222.studio", \
                  "fromName" : "Coin2World", \
                  "to" : rowqq, \
                  "subject" : qq_subject, \
                  "html": qq_html, \
              }
        print (params)
        r = requests.post(url, files={}, data=params)
        print ('send email return '+r.text)
        time.sleep(1)
        break
        


